import config from "./config";

export default {
  // 表单对象属性的复制
  copyObj(source, target) {
    for (let p in source) {
      // eslint-disable-next-line no-prototype-builtins
      if (source.hasOwnProperty(p)) {
        target[p] = source[p];
      }
    }
  },
  // 重置对象属性
  resetObj(obj, val, o) {
    for (let p in obj) {
      // eslint-disable-next-line no-prototype-builtins
      if (obj.hasOwnProperty(p)) {
        obj[p] = val;
        if (o && o.hasOwnProperty(p)) {
          obj[p] = o[p];
        }
      }
    }
  },
  // get auth info
  authInfo() {
    let str = localStorage.getItem(config.authInfo) || "{}";
    return JSON.parse(str);
  },
};
